<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script src="../../assets/libs/id-validator/IDValidator.min.js"></script>
  <script src="../../assets/libs/id-validator/GB2260.min.js"></script>
  <script>
    const validator = new IDValidator(GB2260)

    const idNo = '410803199511200056'
    // 查询身份证号是否合法
    const isValid = validator.isValid(idNo)
    console.log(isValid) // true

    // 获取身份证号信息
    const info = validator.getInfo(idNo)
    /**
     * {
     *   addrCode: '410803',
     *   addr: '河南省焦作市中站区',
     *   birth: '1995-11-20',
     *   sex: 1,
     *   length: 18,
     *   checkBit: '6'
     * }
     */
    console.log(info)

    // 伪造一个ID
    const fakeIdNo = validator.makeID()
    console.log(fakeIdNo)
  </script>
</body>

</html>